package com.distributed.tcp.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * redisBean
 */
@Configuration
public class RestTemplateConfig {

    // 用于IP+端口直接转发的HTTP客户端
    @Bean
    public RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        factory.setConnectTimeout(3000); // 连接超时3秒
        factory.setReadTimeout(5000); // 读取超时5秒
        return new RestTemplate(factory);
    }
}
